package com.database.mapper;


import com.database.character.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

  //查询某级评论
  @Select("select * from comment where comment_type = #{commentType}")
  List<Comment> getByCommentType(Integer commentType);

  //添加评论
  @Insert("insert into comment (reply_article_id, post_id, content, user_id, post_time, comment_type) " +
  "values (#{replyArticleId}, #{postId}, #{content}, #{userId}, #{postTime}, #{commentType})")
  void addComment(Comment comment);

  //删除评论
  @Delete("delete from comment where comment_id = #{commentId}")
  void deleteCommentByCommentId(Integer commentId);

}
